package Process8;

import java.util.concurrent.CountDownLatch;

public class LatchTest {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch=new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            final int j=i;
            Thread t = new Thread() {
                @Override
                public void run() {
                    try {
                        System.out.println(j);
                    } finally {
                        latch.countDown();
                    }
                }
            };
            t.start();
        }
        latch.await();
        System.out.println("main");
    }
}
